<?php
namespace app\user\validate;

use think\Validate;
class AddressValidate extends Validate
{
    protected $rule = [
        'id' => 'require',
        'name' => 'max:21',
        'mobile' => 'require|length:11',
        'area' => 'require',
        'address' => 'require',
        'user_id' => 'require',
    ];

    protected $message = [
        'name.requireIf' => '用户姓名不能为空',
        'name.max' => '用户姓名不能超过21个字符',
        'mobile.require' => '手机号不能为空',
        'mobile.length' => '手机号必须为11位',
        'id.require' => 'id不能为空',
        'area.require' => '地区不能为空',
        'address.require' => '具体地址不能为空',
        'user_id.require' => '用户id不能为空'
    ];

    //验证场景
    protected $scene = [
        'add' => ['user_id','name','mobile','area','address'],
        'edit' => ['id','name','mobile','area','address'],
    ];

}